package csc.fresher.view;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import csc.fresher.entity.SystemUser;

public class SystemUserDataModel extends ListDataModel<SystemUser> implements
		SelectableDataModel<SystemUser> {
	
	public SystemUserDataModel() {
		
	}
	
	public SystemUserDataModel(List<SystemUser> data) {
		super(data);
	}

	@Override
	public SystemUser getRowData(String rowKey) {
		List<SystemUser> systemUsers = (List<SystemUser>) getWrappedData();
		
		for(SystemUser s : systemUsers) {
			if(s.getSystemUserID() == Long.parseLong(rowKey)) {
				return s;
			}
		}
		return null;
	}

	@Override
	public Object getRowKey(SystemUser systemUser) {
		return systemUser.getSystemUserID();
	}


}
